﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.IO;
namespace VCDIFF.Tests
{
    
    
    /// <summary>
    ///This is a test class for CheckSumMD5Test and is intended
    ///to contain all CheckSumMD5Test Unit Tests
    ///</summary>
    [TestClass()]
    public class CheckSumMD5Test
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for verifyMd5Hash
        ///</summary>
        [TestMethod()]
        public void verifyMd5HashTest()
        {
            string text = "hello world";
            File.WriteAllText(@"../../../testFiles/test_file.txt", text);
            string rebuild = @"../../../testFiles/test_file.txt";
            string hashOfModified = CheckSumMD5.getMd5Hash(rebuild);
            bool expected = true;
            bool actual = CheckSumMD5.verifyMd5Hash(rebuild, hashOfModified);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for verifyIntegrity
        ///</summary>
        [TestMethod()]
        public void verifyIntegrityTest()
        {
            string text = "hello world";
            File.WriteAllText(@"../../../testFiles/test_file2.txt", text);
            string original = @"../../../testFiles/test_file2.txt";
            string modified = @"../../../testFiles/test_file2_copy.txt";
            File.Copy(original, modified, true);
            
            bool expected = true;
            bool actual = CheckSumMD5.verifyIntegrity(original, modified);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for getMd5Hash
        ///</summary>
        [TestMethod()]
        public void getMd5HashTest()
        {
            string inputFile = @"../../../testFiles/test_hashcode.txt";
            string expected = "5eb63bbbe01eeed093cb22bb8f5acdc3";
            string actual = CheckSumMD5.getMd5Hash(inputFile); ;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for CheckSumMD5 Constructor
        ///</summary>
        [TestMethod()]
        public void CheckSumMD5ConstructorTest()
        {
            CheckSumMD5 target = new CheckSumMD5();
        }
    }
}
